@extends('layouts/app')

@section('content')
{{-- pment添加设备--}}
<div class="weui-pay append">
    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">部&nbsp;&nbsp;门</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="department" placeholder="请填写设备部门名称">
            </div>
        </div>
    </div>

    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">终端号</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="machinecode" placeholder="4005001900">
            </div>
        </div>
    </div>

    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">密&nbsp;&nbsp;钥</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="machinekey" placeholder="4005001900">
            </div>
        </div>
    </div>
    <div class="demos-content-padded">
        <a href="javascript:;" class="weui-btn weui-btn_blue open-popup">确认</a>
    </div>
</div>
<script>
    var  id = getRequest().id;


    $(".open-popup").click(function () {
        var data = {};
        //参数名
        data['shop_id'] = id;
        //传值设备名称参数
        data['department'] = $("input[name='department']").val();
        //传值设备号
        data['machinecode'] = $("input[name='machinecode']").val();
        //传值密钥
        data['machinekey'] = $("input[name='machinekey']").val();
        //发送请求,接口
        $.post("/api/printer/add", data, function (res) {
            console.log("res", res);
            if(typeof res === 'string'){
                res =JSON.parse(res);
            }
            //判断参数传递,返回结果
            $.alert(res.info,function () {
                if  (res.code === 200){
                    history.go(-1);
                }
            });


        });

    });

</script>
@endsection
@extends('layouts/footer')
